import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/* Router Modules */

/** note: Submenu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  /* {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  }, */
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  /*   {
    path: '/auth-redirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  }, */
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: 'dashboard', icon: 'dashboard', noCache: true }
      }
    ]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  /** When your routing table is too long, you can split it into small modules**/
  {
    path: '/adminManage',
    component: Layout,
    noCache: true,
    meta: {
      title: '管理员管理',
      icon: 'component',
      roles: ['SuperAdmin'] // you can set roles in root nav
    },
    children: [
      {
        path: 'AdminManage',
        component: () => import('@/views/adminManage/AdminManage'),
        name: 'AdminManage',
        meta: {
          title: '管理员管理'
        }
      }
    ]
  },
  {
    path: '/adminLogManage',
    component: Layout,
    meta: {
      title: '操作日志管理',
      icon: 'documentation',
      roles: ['SuperAdmin'] // you can set roles in root nav
    },
    children: [
      {
        path: 'CheckLog',
        component: () => import('@/views/adminLogManage/CheckLog'),
        name: 'CheckLog',
        meta: {
          title: '查看日志'
        }
      },
      {
        path: 'RemoveLog',
        component: () => import('@/views/adminLogManage/RemoveLog'),
        name: 'RemoveLog',
        meta: {
          title: '删除日志'
        }
      },
      {
        path: 'RevokeOperate',
        component: () => import('@/views/adminLogManage/RevokeOperate'),
        name: 'RevokeOperate',
        meta: {
          title: '撤销操作'
        }
      }
    ]
  },
  {
    path: '/schoolManage',
    component: Layout,
    meta: {
      title: '院校管理',
      icon: 'component',
      roles: ['Admin'] // you can set roles in root nav
    },
    children: [
      {
        path: 'SchoolManage',
        component: () => import('@/views/schoolManage/SchoolManage'),
        name: 'SchoolManage',
        meta: {
          title: '院校管理'
        }
      }
    ]
  },
  {
    path: '/log',
    component: Layout,
    redirect: 'noredirect',
    name: 'log',
    meta: {
      title: '管理员操作日志',
      icon: 'documentation',
      roles: ['Admin'] // you can set roles in root nav
    },
    children: [
      {
        path: 'CheckLogs',
        component: () => import('@/views/log/CheckLogs'),
        name: 'CheckLogs',
        meta: {
          title: '查看日志'
        }
      },
      {
        path: 'RemoveLogs',
        component: () => import('@/views/log/RemoveLogs'),
        name: 'RemoveLogs',
        meta: {
          title: '删除日志'
        }
      },
      {
        path: 'Revoke',
        component: () => import('@/views/log/Revoke'),
        name: 'Revoke',
        meta: {
          title: '撤销操作'
        }
      }
    ]
  },
  {
    path: '/systemManage',
    component: Layout,
    redirect: 'noredirect',
    name: 'systemManage',
    meta: {
      title: '系统管理',
      icon: 'component',
      roles: ['School'] // you can set roles in root nav
    },
    children: [
      {
        path: 'SchoolInfo',
        component: () => import('@/views/systemManage/SchoolInfo'),
        name: 'SchoolInfo',
        meta: {
          title: '院校信息修改'
        }
      },
      {
        path: 'DepartmentManage',
        component: () => import('@/views/systemManage/DepartmentManage'),
        name: 'DepartmentManage',
        meta: {
          title: '院系管理'
        }
      },
      {
        path: 'ClassManage',
        component: () => import('@/views/systemManage/ClassManage'),
        name: 'ClassManage',
        meta: {
          title: '班级管理'
        }
      },
      {
        path: 'TeacherEnter',
        component: () => import('@/views/systemManage/TeacherEnter'),
        name: 'TeacherEnter',
        meta: {
          title: '教师录入'
        }
      },
      {
        path: 'StudentEnter',
        component: () => import('@/views/systemManage/StudentEnter'),
        name: 'StudentEnter',
        meta: {
          title: '学生录入'
        }
      }
    ]
  },
  {
    path: '/dataAnalysis',
    component: Layout,
    redirect: 'noredirect',
    name: 'dataAnalysis',
    meta: {
      title: '数据分析',
      icon: 'chart',
      roles: ['School'] // you can set roles in root nav
    },
    children: [
      {
        path: 'DataVisualization',
        component: () => import('@/views/dataAnalysis/DataVisualization'),
        name: 'DataVisualization',
        meta: {
          title: '数据可视化'
        }
      },
      {
        path: 'CourseStats',
        component: () => import('@/views/dataAnalysis/CourseStats'),
        name: 'CourseStats',
        meta: {
          title: '课程统计'
        }
      },
      {
        path: 'StuLearningStats',
        component: () => import('@/views/dataAnalysis/StuLearningStats'),
        name: 'StuLearningStats',
        meta: {
          title: '学生学习情况统计'
        }
      },
      {
        path: 'TrainStats',
        component: () => import('@/views/dataAnalysis/TrainStats'),
        name: 'TrainStats',
        meta: {
          title: '实训统计'
        }
      },
      {
        path: 'StuScoreStats',
        component: () => import('@/views/dataAnalysis/StuScoreStats'),
        name: 'StuScoreStats',
        meta: {
          title: '学生成绩统计'
        }
      },
      {
        path: 'StuAbilityFiles',
        component: () => import('@/views/dataAnalysis/StuAbilityFiles'),
        name: 'StuAbilityFiles',
        meta: {
          title: '学生能力档案'
        }
      }
    ]
  },
  {
    path: '/courseRelated',
    component: Layout,
    redirect: 'noredirect',
    name: 'courseRelated',
    meta: {
      title: '课程相关',
      icon: 'example',
      roles: ['School'] // you can set roles in root nav
    },
    children: [
      {
        path: 'PublishCourse',
        component: () => import('@/views/courseRelated/PublishCourse'),
        name: 'PublishCourse',
        meta: {
          title: '发布课程'
        }
      },
      {
        path: 'AppointTeacher',
        component: () => import('@/views/courseRelated/AppointTeacher'),
        name: 'AppointTeacher',
        meta: {
          title: '指定负责教师'
        }
      },
      {
        path: 'AppointCourse',
        component: () => import('@/views/courseRelated/AppointCourse'),
        name: 'AppointCourse',
        meta: {
          title: '为班级指定课程'
        }
      },
      {
        path: 'PublishTrainPlan',
        component: () => import('@/views/courseRelated/PublishTrainPlan'),
        name: 'PublishTrainPlan',
        meta: {
          title: '发布课程实训计划'
        }
      }
    ]
  },
  {
    path: '/commSupervise',
    component: Layout,
    redirect: 'noredirect',
    name: 'commSupervise',
    meta: {
      title: '交流监管',
      icon: 'peoples',
      roles: ['School'] // you can set roles in root nav
    },
    children: [
      {
        path: 'SuperviseCommCircle',
        component: () => import('@/views/commSupervise/SuperviseCommCircle'),
        name: 'SuperviseCommCircle',
        meta: {
          title: '监管实训交流圈'
        }
      },
      {
        path: 'RemoveCommCircle',
        component: () => import('@/views/commSupervise/RemoveCommCircle'),
        name: 'RemoveCommCircle',
        meta: {
          title: '删除交流圈的内容'
        }
      },
      {
        path: 'TopicManage',
        component: () => import('@/views/commSupervise/TopicManage'),
        name: 'TopicManage',
        meta: {
          title: '话题管理'
        }
      },
      {
        path: 'SetSensitiveWords',
        component: () => import('@/views/commSupervise/SetSensitiveWords'),
        name: 'SetSensitiveWords',
        meta: {
          title: '设置敏感词'
        }
      },
      {
        path: 'SearchCommCircle',
        component: () => import('@/views/commSupervise/SearchCommCircle'),
        name: 'SearchCommCircle',
        meta: {
          title: '交流圈搜索'
        }
      }
    ]
  },
  {
    path: '/portalManage',
    component: Layout,
    redirect: 'noredirect',
    name: 'portalManage',
    meta: {
      title: '门户管理',
      icon: 'tree',
      roles: ['School'] // you can set roles in root nav
    },
    children: [
      {
        path: 'SwiperManage',
        component: () => import('@/views/portalManage/SwiperManage'),
        name: 'SwiperManage',
        meta: {
          title: '轮播图管理'
        }
      },
      {
        path: 'InfoManage',
        component: () => import('@/views/portalManage/InfoManage'),
        name: 'InfoManage',
        meta: {
          title: '资讯管理'
        }
      }
    ]
  },
  {
    path: '/teacherInfo',
    component: Layout,
    redirect: 'noredirect',
    name: 'teacherInfo',
    meta: {
      title: '个人信息',
      icon: 'user',
      roles: ['Teacher'] // you can set roles in root nav
    },
    children: [
      {
        path: 'TeacherInfo',
        component: () => import('@/views/teacherInfo/TeacherInfo'),
        name: 'TeacherInfo',
        meta: {
          title: '个人信息'
        }
      }
    ]
  },
  {
    path: '/checkNews',
    component: Layout,
    redirect: 'noredirect',
    name: 'checkNews',
    meta: {
      title: '查看消息列表',
      icon: 'list',
      roles: ['Teacher'] // you can set roles in root nav
    },
    children: [
      {
        path: 'CheckNews',
        component: () => import('@/views/checkNews/CheckNews'),
        name: 'CheckNews',
        meta: {
          title: '查看消息列表'
        }
      }
    ]
  },
  {
    path: '/taskManage',
    component: Layout,
    redirect: 'noredirect',
    name: 'taskManage',
    meta: {
      title: '任务管理',
      icon: 'form',
      roles: ['Teacher'] // you can set roles in root nav
    },
    children: [
      {
        path: 'PublishTask',
        component: () => import('@/views/taskManage/PublishTask'),
        name: 'PublishTask',
        meta: {
          title: '发布新任务'
        }
      },
      {
        path: 'CheckTask',
        redirect: 'noredirect',
        name: 'CheckTask',
        meta: {
          title: '查看任务列表'
        },
        children: [
          {
            path: 'ByClass',
            component: () => import('@/views/taskManage/ByClass'),
            name: 'ByClass',
            meta: {
              title: '按班级查看'
            }
          },
          {
            path: 'ByStatus',
            component: () => import('@/views/taskManage/ByStatus'),
            name: 'ByStatus',
            meta: {
              title: '按任务状态查看'
            }
          }
        ]
      }
    ]
  },
  {
    path: '/myCourse',
    component: Layout,
    redirect: 'noredirect',
    name: 'myCourse',
    meta: {
      title: '我的课程',
      icon: 'example',
      roles: ['Teacher'] // you can set roles in root nav
    },
    children: [
      {
        path: 'CheckCourse',
        component: () => import('@/views/myCourse/CheckCourse'),
        name: 'CheckCourse',
        meta: {
          title: '查看我负责的课程'
        }
      },
      {
        path: 'EditCoursePoint',
        component: () => import('@/views/myCourse/EditCoursePoint'),
        name: 'EditCoursePoint',
        meta: {
          title: '编辑课程知识点'
        }
      },
      {
        path: 'PublishCourseContent',
        component: () => import('@/views/myCourse/PublishCourseContent'),
        name: 'PublishCourseContent',
        meta: {
          title: '上传课程内容'
        }
      },
      {
        path: 'CheckPractice',
        component: () => import('@/views/myCourse/CheckPractice'),
        name: 'CheckPractice',
        meta: {
          title: '查看学生练习情况'
        }
      },
      {
        path: 'WrongGather',
        component: () => import('@/views/myCourse/WrongGather'),
        name: 'WrongGather',
        meta: {
          title: '学生错题汇总'
        }
      },
      {
        path: 'CheckTrain',
        component: () => import('@/views/myCourse/CheckTrain'),
        name: 'CheckTrain',
        meta: {
          title: '查看课程实训'
        }
      },
      {
        path: 'PublishTopic',
        component: () => import('@/views/myCourse/PublishTopic'),
        name: 'PublishTopic',
        meta: {
          title: '发布实训话题'
        }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
